import 'package:flutter/material.dart';

class LoadingWidget extends StatelessWidget {
  final double size = 30;
  final double dialogPadding = 10;
  final double loadingPaddingTop = 20;
  final double loadingPaddingBottom = 20;
  final Color color = Color.fromRGBO(255, 255, 255, 1);
  final String? title;

  LoadingWidget({
    this.title,
  });

  @override
  Widget build(BuildContext context) {
    Size windowSize = MediaQuery.of(context).size;

    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Container(
          width: windowSize.width / 3,
          padding: EdgeInsets.all(dialogPadding),
          decoration: BoxDecoration(
            color: Color.fromRGBO(0, 0, 0, 0.8),
            borderRadius: BorderRadius.all(
              Radius.circular(10),
            ),
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Container(
                width: size,
                height: size + loadingPaddingBottom + loadingPaddingBottom,
                padding: EdgeInsets.only(
                  top: loadingPaddingTop,
                  bottom: loadingPaddingBottom,
                ),
                margin: EdgeInsets.only(
                  bottom: dialogPadding,
                ),
                child: CircularProgressIndicator(
                  valueColor: new AlwaysStoppedAnimation<Color>(color),
                  strokeWidth: 2,
                ),
              ),
              Text(
                title ?? 'loading...',
                textAlign: TextAlign.center,
                style: TextStyle(
                  color: color,
                  fontSize: 14,
                  decoration: TextDecoration.none,
                ),
              )
            ],
          ),
        ),
      ],
    );
  }
}
